package com.hsc.yalebao.zhuanpan;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.GetAllGiftsBaseBean;
import com.hsc.yalebao.model.GetAllGiftsBean;
import com.hsc.yalebao.model.GiftModel;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.Call;

public class PrizeListActivity extends BaseActivity
{
  private String TAG = "PrizeListActivity";
  public Context context;
  private ImageView iv_title_right;
  private TextView loading_tv;
  private PrizeListAdapter mAdapter;
  private ImageView mBgImageView;
  private GiftModel mGiftModel;
  private ImageView mHeadView;
  private ListView mListView;
  private TextView mNameTv;
  private ScrollView mScrollView;
  private TextView mYuanBaoTv;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
        return;
      case 2131099699:
        CustomApplication.app.finishActivity(PrizeListActivity.this);
        return;
      case 2131099918:
      }
      CustomApplication.app.finishActivity(PrizeListActivity.this);
    }
  };
  private ArrayList<GetAllGiftsBaseBean> result = new ArrayList();

  private void GetAllGifts()
  {
    HashMap localHashMap = new HashMap();
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GETALLGIFTS);
    showLoadingDialog();
    RequestNet.get(this.context, AppConstants.URL_GETALLGIFTS, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        PrizeListActivity.this.dismissLoadingDialog();
        PrizeListActivity.this.loading_tv.setText("获取数据失败");
        LogUtils.e(PrizeListActivity.this.TAG, "获取失败,GetAllGifts-result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        PrizeListActivity.this.dismissLoadingDialog();
        LogUtils.d(PrizeListActivity.this.TAG, "-------GetAllGifts:" + paramAnonymousString);
        Gson localGson = new Gson();
        try
        {
          localGetAllGiftsBean = (GetAllGiftsBean)localGson.fromJson(paramAnonymousString, GetAllGiftsBean.class);
          if (localGetAllGiftsBean == null)
            return;
        }
        catch (Exception localException)
        {
          GetAllGiftsBean localGetAllGiftsBean;
          do
          {
            do
            {
              while (true)
              {
                localException.printStackTrace();
                localGetAllGiftsBean = null;
              }
              if (localGetAllGiftsBean.getFlag() == -4)
              {
                PrizeListActivity.activityStack.backToMain(MainActivity.class, PrizeListActivity.this);
                return;
              }
            }
            while (localGetAllGiftsBean.getFlag() == 0);
            if (localGetAllGiftsBean.getFlag() == -2)
            {
              PrizeListActivity.this.showDownWireDialog();
              return;
            }
            if (localGetAllGiftsBean.getFlag() == -3)
            {
              PrizeListActivity.this.ShowFengjinDialog();
              return;
            }
          }
          while (localGetAllGiftsBean.getFlag() != 1);
          if (localGetAllGiftsBean.getResult() == null)
          {
            LogUtils.e(PrizeListActivity.this.TAG, "bean.getResult() == null");
            return;
          }
          PrizeListActivity.this.result.addAll(localGetAllGiftsBean.getResult());
          if (localGetAllGiftsBean.getResult().size() != 0)
            PrizeListActivity.this.loading_tv.setVisibility(8);
          PrizeListActivity.this.initData();
        }
      }
    });
  }

  private void initData()
  {
    if (this.result == null)
      return;
    if (this.mAdapter == null)
    {
      this.mAdapter = new PrizeListAdapter(this, this.result);
      this.mListView.setAdapter(this.mAdapter);
    }
    while (true)
    {
      setListViewHeightBasedOnChildren(this.mListView);
      this.mScrollView.smoothScrollTo(0, 20);
      return;
      this.mAdapter.notifyDataSetChanged();
    }
  }

  private void initView()
  {
    this.mScrollView = ((ScrollView)findViewById(2131099919));
    this.mBgImageView = ((ImageView)findViewById(2131099920));
    this.mHeadView = ((ImageView)findViewById(2131099921));
    this.mNameTv = ((TextView)findViewById(2131099922));
    this.mYuanBaoTv = ((TextView)findViewById(2131099923));
    this.mYuanBaoTv.setText(this.mGiftModel.getMoney());
    String str1;
    if (CustomApplication.app.userBaseBean != null)
    {
      str1 = CustomApplication.app.userBaseBean.getNick_name();
      CustomApplication.app.userBaseBean.getSignature();
      if ((str1 != null) && (!"".equals(str1)))
        break label223;
      this.mNameTv.setText("暂无昵称");
      String str2 = CustomApplication.app.userBaseBean.getUser_logo();
      if ((str2 == null) || ("".equals(str2)))
        break label234;
      UiUtil.loadImage(AppConstants.BASE_URL_IMG + str2, this, this.mHeadView);
    }
    while (true)
    {
      this.loading_tv = ((TextView)findViewById(2131099803));
      this.mListView = ((ListView)findViewById(2131099924));
      this.mListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
      {
        public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
        {
        }
      });
      return;
      label223: this.mNameTv.setText(str1);
      break;
      label234: this.mHeadView.setImageResource(2130838020);
    }
  }

  public static void setListViewHeightBasedOnChildren(ListView paramListView)
  {
    ListAdapter localListAdapter = paramListView.getAdapter();
    if (localListAdapter == null)
      return;
    int i = 0;
    for (int j = 0; ; j++)
    {
      if (j >= localListAdapter.getCount())
      {
        ViewGroup.LayoutParams localLayoutParams = paramListView.getLayoutParams();
        localLayoutParams.height = (i + paramListView.getDividerHeight() * (-1 + localListAdapter.getCount()));
        paramListView.setLayoutParams(localLayoutParams);
        return;
      }
      View localView = localListAdapter.getView(j, null, paramListView);
      localView.measure(0, 0);
      i += localView.getMeasuredHeight();
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903075);
    Bundle localBundle = getIntent().getExtras();
    if (localBundle != null)
      this.mGiftModel = ((GiftModel)localBundle.getSerializable("data"));
    this.context = this;
    setTitle(8, 8, 2130837809, "PC蛋蛋红包", 0, 8, 8, 0, true);
    initView();
    GetAllGifts();
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    ((TextView)findViewById(2131099918)).setOnClickListener(this.onClickListener);
    ((TextView)findViewById(2131099701)).setText(paramString);
    ((TextView)findViewById(2131099700)).setVisibility(paramInt1);
    ImageView localImageView = (ImageView)findViewById(2131099699);
    localImageView.setVisibility(paramInt2);
    localImageView.setOnClickListener(this.onClickListener);
    localImageView.setImageResource(paramInt3);
    ((TextView)findViewById(2131099702)).setVisibility(paramInt5);
    ((ImageView)findViewById(2131099703)).setVisibility(8);
    this.iv_title_right = ((ImageView)findViewById(2131099704));
    this.iv_title_right.setVisibility(paramInt6);
    this.iv_title_right.setImageResource(paramInt7);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.zhuanpan.PrizeListActivity
 * JD-Core Version:    0.6.2
 */